﻿<Page x:Class="CAION2.Views.RandomBonusPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:viewModels="clr-namespace:CAION2.ViewModels"
      xmlns:mui="http://firstfloorsoftware.com/ModernUI"
      xmlns:resources="clr-namespace:CAION2.Properties"
      xmlns:classes="clr-namespace:CAION2.Classes">
    
    <Page.DataContext>
        <viewModels:RandomBonusViewModel />
    </Page.DataContext>

    <Page.Resources>
        <viewModels:IdianRandomTextConverter x:Key="IdianRandomTextConverter" />
    </Page.Resources>
    
    <Grid Style="{StaticResource ContentRoot}">
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <mui:ModernButton Grid.Row="0"
                          HorizontalAlignment="Right"
                          VerticalAlignment="Center"
                          Command="{Binding DeleteRandomBonusCommand}"
                          IconData="{StaticResource ClearIcon}"
                          ToolTip="{x:Static resources:Resources.RandomBonus_DeleteRandomBonus}" />

        <ListBox Grid.Row="1"
                 MaxHeight="300"
                 Margin="10,0,0,0"
                 VerticalAlignment="Stretch"
                 VerticalContentAlignment="Stretch"
                 IsSynchronizedWithCurrentItem="True"
                 ItemsSource="{Binding RandomBonusesList}"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 ScrollViewer.VerticalScrollBarVisibility="Auto"
                 SelectedItem="{Binding SelectedRandomBonus,
                                        Mode=TwoWay,
                                        UpdateSourceTrigger=PropertyChanged}">
            <ListBox.ItemTemplate>
                <DataTemplate DataType="{x:Type classes:RandomBonus}">
                    <StackPanel Orientation="Horizontal" Width="700" Height="50">
                        <TextBlock Width="50"
                                   Margin="5,0,2,0"
                                   VerticalAlignment="Top"
                                   Text="{Binding Chance}" />
                        
                        <WrapPanel Orientation="Horizontal" Width="600" ItemWidth="150">
                            <WrapPanel.Resources>
                                <Style x:Key="RandomBonusBlockStyle" TargetType="mui:BBCodeBlock">
                                    <Setter Property="Width" Value="150" />
                                    <Setter Property="VerticalAlignment" Value="Center" />
                                    <Setter Property="TextWrapping" Value="Wrap" />
                                </Style>
                            </WrapPanel.Resources>
                            <mui:BBCodeBlock BBCode="{Binding RandomBonuses[0],
                                                              Converter={StaticResource IdianRandomTextConverter}}"
                                             Style="{StaticResource RandomBonusBlockStyle}" />
                            <mui:BBCodeBlock BBCode="{Binding RandomBonuses[1],
                                                              Converter={StaticResource IdianRandomTextConverter}}"
                                             Style="{StaticResource RandomBonusBlockStyle}" />
                            <mui:BBCodeBlock BBCode="{Binding RandomBonuses[2],
                                                              Converter={StaticResource IdianRandomTextConverter}}"
                                             Style="{StaticResource RandomBonusBlockStyle}" />
                            <mui:BBCodeBlock BBCode="{Binding RandomBonuses[3],
                                                              Converter={StaticResource IdianRandomTextConverter}}"
                                             Style="{StaticResource RandomBonusBlockStyle}" />
                            <mui:BBCodeBlock BBCode="{Binding RandomBonuses[4],
                                                              Converter={StaticResource IdianRandomTextConverter}}"
                                             Style="{StaticResource RandomBonusBlockStyle}" />
                            <mui:BBCodeBlock BBCode="{Binding RandomBonuses[5],
                                                              Converter={StaticResource IdianRandomTextConverter}}"
                                             Style="{StaticResource RandomBonusBlockStyle}" />
                            <mui:BBCodeBlock BBCode="{Binding RandomBonuses[6],
                                                              Converter={StaticResource IdianRandomTextConverter}}"
                                             Style="{StaticResource RandomBonusBlockStyle}" />
                            <mui:BBCodeBlock BBCode="{Binding RandomBonuses[7],
                                                              Converter={StaticResource IdianRandomTextConverter}}"
                                             Style="{StaticResource RandomBonusBlockStyle}" />
                        </WrapPanel>
                    </StackPanel>
                    
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

    </Grid>
</Page>
